<?php

/**
 * ClassName:
 * @auditor LeiJunXiang
 * @time 2024/09/30
 */

namespace app\tool;

class ToolBase
{
    //对象key
    protected $objKey;
    //错误信息
    protected $errMsg = "";
    //错误码
    protected $errCode = SUCCESS;

    /**
     * 是否继续执行
     */
    protected function isGoOn()
    {
        $flag = false;
        if ($this->errCode == SUCCESS) {
            $flag = true;
        }
        return $flag;
    }

    /**
     * 生成唯一编号
     * @return string
     */
    public function createUniqueNumber() {
        // 生成一个 4 位的随机数
        $randomPart = mt_rand(1000, 9999);
        // 截取时间戳的第 8 位之后的数字
        $timePart = substr((string)time(), 5);
        // 拼接生成的编号
        return $timePart . $randomPart;
    }

    /**
     * 初始化数据
     */

    protected function init()
    {
        $this->errMsg = "";
        $this->errCode = SUCCESS;
    }

    /**
     * @return mixed
     */
    public function getObjKey()
    {
        return $this->objKey;
    }

    /**
     * @param mixed $objKey
     */
    public function setObjKey($objKey): void
    {
        $this->objKey = $objKey;
    }

    /**
     * @return mixed
     */
    public function getErrMsg()
    {
        return $this->errMsg;
    }

    /**
     * @param mixed $errMsg
     */
    public function setErrMsg($errMsg): void
    {
        $this->errMsg = $errMsg;
    }

    /**
     * @return mixed
     */
    public function getErrCode()
    {
        return $this->errCode;
    }

    /**
     * @param mixed $errCode
     */
    public function setErrCode($errCode): void
    {
        $this->errCode = $errCode;
    }


}